/* ****************************************************************** 
   File name: C_TCP_Format_WSA_Text.cpp
   Associated Files necessary to complete this utility:
   C_Log_File_Writer.cpp
   C_Log_Writer.h
   C_TCP_Format_WSA_Text.h


********************************************************************* */

/* ******************************************************************
    (C) Copyright 2012/2013 Bryan Kelly
    This file is part of the software utility named:
    Bryan Kelly's Utility Kit for Microsoft Windows.
    The short name is Bryan Kelly's Utility Kit.

    Bryan Kelly's Utility Kit is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Bryan Kelly's Utility Kit is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with BK TCP/IP Starter.  If not, see <http://www.gnu.org/licenses/>.

    EXCEPTION to the GNU license for this application:  
    United States Government, U.S. Dod, and other U.S. government agencies
    may use this and all derived or similar utilities for non-commercial
    use without the copyright notice.
********************************************************************* */


#include "stdafx.h"
#include "C_TCP_Format_WSA_Text.h"

namespace FWSA = NS_C_TCP_FORMAT_WSA;
using namespace FWSA;

C_TCP_Format_WSA_Text::C_TCP_Format_WSA_Text( )
{
}

C_TCP_Format_WSA_Text::~C_TCP_Format_WSA_Text()
{
}

void C_TCP_Format_WSA_Text::Format_WSA_Error_As_Text( int wsa_error, WCHAR*  wsa_text )
{

   switch(wsa_error)
   {
   case 0:
      wcscpy_s( wsa_text, MAX_WSA_ERROR_TEXT, L"OK" );
      break;
 case WSA_INVALID_PARAMETER: // 87
      wcscpy_s( wsa_text, MAX_WSA_ERROR_TEXT, L"One or more parameters are invalid." );
      break;
 case WSA_IO_PENDING: // 997
      wcscpy_s( wsa_text, MAX_WSA_ERROR_TEXT, L"Overlapped operations will complete later." );
      break;
    case WSAEACCES:       //  10013
      wcscpy_s( wsa_text, MAX_WSA_ERROR_TEXT, L"Permission denied.");
      break;
    case WSAEFAULT:       //  10014
      wcscpy_s( wsa_text, MAX_WSA_ERROR_TEXT, L"IpSockAddrLen: bad pointer or bad length.");
      break;
  case WSAEINVAL:         //  10022
      wcscpy_s( wsa_text, MAX_WSA_ERROR_TEXT, L"The socket is already bound to an address.");
      break;
  case WSAEINPROGRESS:
      wcscpy_s( wsa_text, MAX_WSA_ERROR_TEXT, L"A blocking operation is already in progress.");
      break;
  case WSAEMFILE:         //  10024
      wcscpy_s( wsa_text, MAX_WSA_ERROR_TEXT, L"No more file descriptors are available.");
      break;
  case WSAEWOULDBLOCK:    //  10035
      wcscpy_s( wsa_text, MAX_WSA_ERROR_TEXT, L"Data not sent, wait for OnSend( ) and try again.");
      break;
   case WSAENOTSOCK:      //  10038
      wcscpy_s( wsa_text, MAX_WSA_ERROR_TEXT, L"The descriptor is a file, not a socket.");
      break;
   case WSAEDESTADDRREQ:  //  10039
      wcscpy_s( wsa_text, MAX_WSA_ERROR_TEXT, L"A destination address is required.");
      break;
   case WSAEPROTOTYPE:  //  10041
      wcscpy_s( wsa_text, MAX_WSA_ERROR_TEXT, L"Protocol wrong type for requests socket type.");
      break;
   case WSAENOPROTOOPT:  //  10042
      wcscpy_s( wsa_text, MAX_WSA_ERROR_TEXT, L"Bat protocol option.");
      break;
   case WSAEPROTONOSUPPORT :  //  10043
      wcscpy_s( wsa_text, MAX_WSA_ERROR_TEXT, L"Protocol not supported.");
      break;
   case WSAESOCKTNOSUPPORT :  //  10044
      wcscpy_s( wsa_text, MAX_WSA_ERROR_TEXT, L"Socket type not supported.");
      break;
   case WSAEOPNOTSUPP :  //  10045
      wcscpy_s( wsa_text, MAX_WSA_ERROR_TEXT, L"Operation not supported.");
      break;
   case WSAEPFNOSUPPORT :  //  10046
      wcscpy_s( wsa_text, MAX_WSA_ERROR_TEXT, L"Protocol famile not supported.");
      break;
   case WSAEAFNOSUPPORT:  //  10047
      wcscpy_s( wsa_text, MAX_WSA_ERROR_TEXT, L"Addresses in the specified family cannot be used with this socket.");
      break;
   case WSAEADDRINUSE:   //  10048
      wcscpy_s( wsa_text, MAX_WSA_ERROR_TEXT, L"The specified address is already in use.");
      break;
   case WSAEADDRNOTAVAIL: // 10049
      wcscpy_s( wsa_text, MAX_WSA_ERROR_TEXT, L"The specified address is not available from the local machine");
      break;
   case WSAENETDOWN:      // 10050
      wcscpy_s( wsa_text, MAX_WSA_ERROR_TEXT, L"The network is down.");
      break;
   case WSAENETUNREACH:   // 10051
      wcscpy_s( wsa_text, MAX_WSA_ERROR_TEXT, L"The network cannot be reached from this host at this time.");
      break;
   case WSAENETRESET:    // 10052
      wcscpy_s( wsa_text, MAX_WSA_ERROR_TEXT, L"Network dropped connection on reset.");
      break;
   case WSAECONNABORTED: //  10053
      wcscpy_s( wsa_text, MAX_WSA_ERROR_TEXT, L"Software abort.");
      break;
  case WSAECONNRESET:    //  10054
      wcscpy_s( wsa_text, MAX_WSA_ERROR_TEXT, L"Connection reset by peer.");
      break;  
  case WSAENOBUFS:       //  10055
      wcscpy_s( wsa_text, MAX_WSA_ERROR_TEXT, L"No buffer space is available. The socket cannot be connected.");
      break;
   case WSAEISCONN:      //  10056
      wcscpy_s( wsa_text, MAX_WSA_ERROR_TEXT, L"The socket is already connected.");
      break;
   case WSAENOTCONN:     //  10057
      wcscpy_s( wsa_text, MAX_WSA_ERROR_TEXT, L"The socket is not connected.");
      break;
   case WSAESHUTDOWN:     //  10058
      wcscpy_s( wsa_text, MAX_WSA_ERROR_TEXT, L"Cannot send after socket shutdown.");
      break; 
   case WSAETIMEDOUT:     //  10060
      wcscpy_s( wsa_text, MAX_WSA_ERROR_TEXT, L"The attempt to connect timed out without establishing a connection.");
      break;
   case WSAECONNREFUSED:  // 10061
      wcscpy_s( wsa_text, MAX_WSA_ERROR_TEXT, L"The attempt to connect was forcefully rejected.");
      break;
   case WSAEPROCLIM:      // 10067
      wcscpy_s( wsa_text, MAX_WSA_ERROR_TEXT, L"Too many Windoes Sockets processes.");
      break;
   case WSASYSNOTREADY:   //  10091
      wcscpy_s( wsa_text, MAX_WSA_ERROR_TEXT, L"Network system is not available.");
      break;
   case WSAVERNOTSUPPORTED:   //  10092
      wcscpy_s( wsa_text, MAX_WSA_ERROR_TEXT, L"Version requested is not supported.");
      break;
   case WSANOTINITIALISED:   //  10093
      wcscpy_s( wsa_text, MAX_WSA_ERROR_TEXT, L"Not Initialized.  WSAStartup not performed.");
      break;
   case WSAEDISCON:   //  10101
      wcscpy_s( wsa_text, MAX_WSA_ERROR_TEXT, L"Shutdown in progress.");
      break;
   case WSAENOMORE:   //  10102
      wcscpy_s( wsa_text, MAX_WSA_ERROR_TEXT, L"No more results.");
      break;
   case WSAECANCELLED:   //  10103
      wcscpy_s( wsa_text, MAX_WSA_ERROR_TEXT, L"Call has been canceled.");
      break;
   default:
      wcscpy_s( wsa_text, MAX_WSA_ERROR_TEXT, L"This error not in Format_WSA_Error_As_Text()");
      break;
   }




}